﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QuanLyThuNgan
{
    public partial class frmLogin :frmLoading
    {
        public frmLogin()
        {
            InitializeComponent();
          //  CreateWaitDialog();
        }
        public static NguoiDungDTO nd = new NguoiDungDTO();
        private void btnLogin_Click(object sender, EventArgs e)
        {
            NguoiDungCTL ctlND = new NguoiDungCTL();
            DataTable dt=ctlND.SelectALL();
            foreach (DataRow dr in dt.Rows)
            {
                if (txtUserName.Text.Trim() == dr["TenNguoiDung"].ToString().Trim() &&
                   txtPass.Text.Trim() == Uit.it_Encryt.Encrytion(dr["MatKhau"].ToString().Trim()))
                {
                    nd.IDNguoiDung = int.Parse(dr["IDNguoiDung"].ToString());
                    nd.HoTen = dr["HoTen"].ToString();
                    nd.MaDonVi = dr["MaDonVi"].ToString();
                    nd.TenMaDonVi = dr["TenDonVi"].ToString();
                    nd.TinhTrang = true;
                    nd.TenNguoiDung = dr["HoTen"].ToString();
                    this.Close();
                }
            }
            if (nd.TinhTrang==false)
             XtraMessageBox.Show("Nhập sai tên hoăc mật khẩu");
               
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            nd.Thoat = true;
            this.Close();
         
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            //---Load hinh nen
           // SetWaitDialogCaption("Đang load dử liệu..");
            //DataTable dt = user.selectall();
            //frmKetQua.m_loadLookupEdit(dt,lookUpEdit_ChucVu,"tenquyen","quyenid");
            //lookUpEdit_ChucVu.EditValue = 2;
            //lookUpEdit_ChucVu.Properties.Columns["quyenid"].Visible = false;
        
        }

        private void groupControl1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}